﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Less2DB.CodeGenerator.FormUI
{
    using System.Drawing;
    using System.Diagnostics;

    partial class DdfaultFormUI : IFormUI
    {
        void IFormUI.Render(System.Windows.Forms.Form form, bool background)
        {
            if (background)
            {
                form.BackgroundImage = CreateBackgroundImage();
                form.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Tile;
            }

            form.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
            form.Font = new Font("微软雅黑", 9);
        }

        private Image CreateBackgroundImage()
        {
            var imgSize = new Size(300, 300);
            var image = new Bitmap(imgSize.Width, imgSize.Height);
            var graphic = Graphics.FromImage(image);
            var darkBrush = new SolidBrush(Color.FromArgb(43, 59, 88));
            var lightBrush = new SolidBrush(Color.FromArgb(53, 57, 106));
            var pen = new Pen(lightBrush, 1);

            graphic.FillRectangle(darkBrush, new Rectangle(Point.Empty, imgSize));

            for (int y = 1, yLen = imgSize.Height; y < yLen; y += 3)
            {
                for (int x = 1, xLen = imgSize.Width; x < xLen; x += 3)
                {
                    graphic.FillRectangle(lightBrush, x, y, 1, 1);
                    graphic.DrawRectangle(pen, x, y, 1, 1);
                }
            }

            darkBrush.Dispose();
            lightBrush.Dispose();
            pen.Dispose();
            graphic.Dispose();

            return image;
        }

        Color IFormUI.BackColorTextboxPanel
        {
            get { return Color.FromArgb(188, 199, 216); }
        }
    }
}
